package com.gjp.controller;

import com.gjp.bean.User;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import java.util.*;

/**
 * Created by 郭金鹏 on 2017/5/29.
 */
@RestController
public class IndexController {

    @GetMapping()
    public ModelAndView index(){
        ModelAndView modelAndView = new ModelAndView("index");
        modelAndView.addObject("message",101);
        modelAndView.addObject("age",21L);
        modelAndView.addObject("flag",true);
        modelAndView.addObject("date",new Date());
        modelAndView.addObject("nul",null);

        User user = new User();
        user.setName("郭金鹏");
        user.setAge(21);
        modelAndView.addObject("user",user);

        List<String> list = new ArrayList<>();
        list.add("Java");
        list.add("C++");
        list.add("HTML");
        modelAndView.addObject("list",list);

        Map<String,String> map = new HashMap<>();
        map.put("1","java");
        map.put("2","C++");
        map.put("3","HTML");
        modelAndView.addObject("map",map);


        return modelAndView;
    }
}
